:root {
  --bg: #e6e8ec;
  --card: #f7f7f7;
  --text: #101010;
  --line: #2b2b2b;
  --accent: #111111;
  --brand-red: #be1e2d;
  --brand-red-dark: #8f1622;
  --brand-blue: #5f89ad;
  --brand-blue-dark: #4e7190;
  --steel: #d7dbe0;
  --catalog-sticky-top: 0px;
  --catalog-sticky-category-height: 48px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #f5f6f8 0%, #dfe3e9 55%, #d3d8df 100%);
}

.sheet-header {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 14px 16px;
  background: #ffffff;
  border: 2px solid var(--accent);
  border-top: 6px solid var(--brand-red);
  border-bottom: 4px solid var(--brand-blue);
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 88px;
  align-items: center;
  position: relative;
}

.sheet-brand {
  grid-column: 2;
  width: 100%;
  display: flex;
  justify-content: center;
}

.sheet-logo {
  width: min(100%, 520px);
  height: auto;
  display: block;
  margin: 0 auto;
}

.sheet-header-actions {
  grid-column: 3;
  justify-self: end;
  position: static;
  display: flex;
  gap: 8px;
  align-items: center;
}

.main-site-btn {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--brand-blue);
  border: 1px solid var(--brand-blue-dark);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.main-site-btn:hover {
  filter: brightness(0.92);
}

.sheet-container {
  max-width: 1200px;
  margin: 10px auto 24px;
  padding: 0 16px 66px;
}

.mobile-sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  max-height: 56px;
  padding: 6px 12px;
  background: linear-gradient(90deg, #5f89ad 0%, #4e7190 100%);
  border-top: 3px solid #be1e2d;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.mobile-main-site-btn {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 6px;
  background: #be1e2d;
  border: 1px solid #8f1622;
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.mobile-main-site-btn:hover {
  filter: brightness(0.93);
}

.mobile-sticky-note {
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-controls,
.actions,
.item-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.item-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.store-select-panel {
  position: relative;
  width: 100%;
  max-width: none;
  padding: 6px 12px 6px 18px;
  border: 1px solid #406889;
  border-radius: 0;
  background: linear-gradient(180deg, #6f95b8 0%, #648caf 100%);
  color: #fff;
}

.sticky-store-panel {
  position: sticky;
  top: 0;
  z-index: 28;
  margin: 0;
  box-shadow: 0 2px 8px rgba(10, 20, 30, 0.12);
}

.store-select-panel::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: var(--brand-red);
}

.store-select-caption {
  font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  line-height: 1;
  margin-bottom: 2px;
  opacity: 0.95;
}

.store-select-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.store-select-meta {
  min-width: 0;
}

.store-select-value {
  color: #fff;
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.03em;
  line-height: 1;
  text-transform: uppercase;
  min-width: 0;
  overflow-wrap: anywhere;
}

.store-order-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  white-space: nowrap;
}

.store-order-link.disabled {
  opacity: 0.78;
  pointer-events: none;
}

.store-action-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  color: #fff;
  padding: 6px 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.store-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.store-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 20, 30, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.store-modal-card {
  width: min(96vw, 480px);
  background: #fff;
  border: 2px solid var(--line);
  border-top: 6px solid var(--brand-red);
  border-bottom: 4px solid var(--brand-blue);
  padding: 16px;
  position: relative;
}

.store-modal-card h2 {
  margin: 0 0 8px;
}

.store-modal-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  line-height: 1;
  font-size: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #1f2937;
  border: 1px solid #94a3b8;
  padding: 0;
}

.store-modal-card p {
  margin: 0 0 10px;
}

.store-modal-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.zip-lookup-msg {
  min-height: 18px;
  margin: 8px 0;
  font-size: 0.9rem;
  color: #334155;
}

.county-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.county-option-btn {
  text-align: left;
  width: 100%;
}

input,
select,
button,
textarea {
  padding: 10px 12px;
  border: 1px solid #8f8f8f;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

textarea {
  width: 100%;
  resize: vertical;
}

button {
  background: var(--brand-red);
  color: #fff;
  cursor: pointer;
  border: 1px solid var(--brand-red-dark);
}

button:hover {
  filter: brightness(0.92);
}

button.secondary-action {
  background: #64748b;
  border-color: #475569;
}

button.secondary-action:hover {
  filter: brightness(0.96);
}

button.danger-action {
  background: #991b1b;
  border-color: #7f1d1d;
}

button.danger-action:hover {
  filter: brightness(0.95);
}

.search-action-note {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}

.catalog-sections {
  display: grid;
  gap: 12px;
}

.catalog-section {
  background: #fff;
  border: 2px solid var(--accent);
  border-top: 6px solid var(--brand-red);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.catalog-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(90deg, #be1e2d 0%, #a31825 100%);
  border-bottom: 2px solid #8f1622;
  position: sticky;
  top: var(--catalog-sticky-top);
  z-index: 16;
}

.catalog-section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
}

.catalog-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  opacity: 0.95;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--card);
}

.catalog-subsection {
  border-top: 1px solid #c9d3de;
}

.catalog-subsection:first-of-type {
  border-top: 0;
}

.catalog-subsection-title {
  padding: 6px 10px;
  background: linear-gradient(90deg, #6f95b8 0%, #5f89ad 100%);
  border-bottom: 1px solid #4e7190;
  border-left: 4px solid #be1e2d;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  position: sticky;
  top: calc(var(--catalog-sticky-top) + var(--catalog-sticky-category-height));
  z-index: 15;
}

.catalog-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #c6ced7;
  border-left: 4px solid var(--brand-blue);
  background: #fff;
  min-width: 0;
}

.catalog-item.no-image {
  padding: 6px 8px;
}

.catalog-item.is-hidden {
  opacity: 0.55;
}

.catalog-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.catalog-item.no-image .catalog-item-main {
  gap: 0;
}

.catalog-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #bcc6d1;
  flex: 0 0 auto;
}

.catalog-thumb-empty {
  background: #f1f3f6;
}

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

.catalog-code {
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.catalog-desc {
  font-size: 0.92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.catalog-price {
  flex: 0 0 auto;
  font-size: 1rem;
  font-weight: 800;
  color: #202a35;
  white-space: nowrap;
}

.grouped-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 88px;
}

.grouped-item-actions button {
  padding: 6px 8px;
  font-size: 0.75rem;
}

.catalog-link-item .catalog-code {
  color: var(--brand-blue-dark);
}

.catalog-link-item .catalog-desc a,
.catalog-link-item .catalog-price a {
  color: #0f3b5f;
  text-decoration: underline;
  font-weight: 700;
}

.admin-public-override-flag {
  margin-top: 2px;
  font-size: 0.7rem;
  color: #0c4a6e;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.subcategory-override-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px 12px;
}

.subcategory-override-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
}

.subcategory-source {
  font-size: 0.85rem;
  font-weight: 700;
}

.subcategory-display-input {
  min-width: 0;
}


.sheet-footer {
  margin-top: 14px;
  padding: 12px;
  background: #fff;
  border: 2px solid var(--accent);
  border-bottom: 6px solid var(--brand-red);
  border-top: 4px solid var(--brand-blue);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--brand-blue);
  outline-offset: 1px;
}

.empty-state {
  text-align: center;
  font-weight: 600;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #d1d5db;
  background: #ffffff;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
}

h2 {
  margin-top: 0;
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

.admin-link {
  color: #111111;
  text-decoration: none;
  font-weight: 600;
}

.card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 16px;
}

.sync-status-card {
  margin-bottom: 12px;
}

.sync-status-card h3 {
  margin: 0 0 8px;
}

.sync-status-card p {
  margin: 4px 0;
}

.provider-switch {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  align-items: center;
}

.provider-switch label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.msg {
  min-height: 20px;
  color: #6b7280;
}

.hidden {
  display: none;
}

.admin-layout {
  display: grid;
  gap: 16px;
}

.category-preview-meta {
  margin: 8px 0;
  color: #374151;
  font-size: 14px;
}

.category-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}

.category-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
}

.category-order-select {
  margin-left: auto;
  width: 90px;
  max-width: 90px;
  padding: 6px 8px;
}

.category-empty {
  color: #6b7280;
  font-style: italic;
}

.admin-image-cell {
  min-width: 72px;
}

.admin-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #8f8f8f;
}

.upload-label {
  display: inline-block;
  margin-left: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #fff;
  background: var(--brand-blue);
  border: 1px solid var(--brand-blue-dark);
  font-size: 13px;
  cursor: pointer;
}

.upload-label input[type='file'] {
  display: none;
}

@media (max-width: 820px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .sheet-controls,
  .actions,
  .item-form {
    grid-template-columns: 1fr;
  }

  .store-select-panel {
    max-width: none;
    padding: 10px 10px 8px 18px;
  }

  .sticky-store-panel {
    margin: 0;
  }

  .store-select-value {
    font-size: 1.65rem;
  }

  .store-modal-actions {
    grid-template-columns: 1fr;
  }

  .sheet-footer {
    flex-direction: column;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 6px;
  }

  .subcategory-override-row {
    grid-template-columns: 1fr;
  }

  .catalog-subsection-title {
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .sheet-container {
    padding: 0 10px 64px;
  }

  .mobile-sticky-bar {
    gap: 8px;
    height: 52px;
    max-height: 52px;
    padding: 5px 8px;
  }

  .mobile-main-site-btn {
    padding: 7px 9px;
    font-size: 10px;
  }

  .mobile-sticky-note {
    font-size: 10px;
  }
}

.print-btn {
  background: var(--brand-blue);
  border-color: var(--brand-blue-dark);
}

@media print {
  @page {
    size: Letter portrait;
    margin: 3mm;
  }

  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding-bottom: 6mm;
  }

  .sheet-controls,
  .store-select-panel,
  .main-site-btn,
  .print-btn,
  .store-modal,
  button {
    display: none !important;
  }

  .sheet-footer {
    display: none !important;
  }

  .mobile-sticky-bar {
    display: none !important;
  }

  .sheet-container,
  .sheet-header {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .sheet-header {
    border: 0 !important;
    padding: 0.2mm 0 !important;
    margin-bottom: 0.2mm !important;
  }

  .sheet-logo {
    width: 165px;
    max-width: 52%;
    height: auto;
    object-fit: contain;
  }

  .catalog-section {
    border: 0 !important;
    margin-bottom: 0.4mm;
    background: transparent;
  }

  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding: 0;
    background: transparent;
  }

  .catalog-subsection-title {
    padding: 0.2px 0.8px;
    font-size: 5.6pt;
    border-bottom: 0.4px solid #4e7190;
    border-left: 2px solid #be1e2d;
    background: #d8e5f1;
    color: #14324b;
    font-weight: 700;
  }

  .catalog-section-head {
    padding: 0.2px 0.8px;
    border-bottom: 0.5px solid #8f1622;
    background: #f3d7da;
  }

  .catalog-section-head h2 {
    font-size: 5.9pt;
    color: #7f111b;
    letter-spacing: 0.03em;
    font-weight: 800;
  }

  .catalog-count {
    display: none;
  }

  .catalog-item {
    padding: 0.2px 0.8px;
    gap: 0.8px;
    border: 0.5px solid #111;
    border-radius: 0;
    background: transparent;
  }

  .catalog-thumb {
    display: none;
  }

  .catalog-item-main {
    gap: 0;
    flex: 1 1 auto;
    min-width: 0;
  }

  .catalog-copy {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 2px;
    min-width: 0;
    width: 100%;
  }

  .catalog-code {
    flex: 0 0 auto;
    font-weight: 700;
    white-space: nowrap;
  }

  .catalog-desc {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }

  .catalog-code,
  .catalog-desc,
  .catalog-price {
    font-size: 5.8pt;
    line-height: 1.02;
  }

  .catalog-price {
    flex: 0 0 auto;
    margin-left: 3px;
    white-space: nowrap;
    text-align: right;
  }

  .catalog-section,
  .catalog-subsection {
    break-inside: auto;
    page-break-inside: auto;
  }

  .catalog-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .catalog-section-head,
  .catalog-subsection-title {
    position: static !important;
    top: auto !important;
  }

  .catalog-section[data-print-enabled='0'] {
    display: none !important;
  }


  body::after {
    content: attr(data-print-footer);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0.8mm;
    text-align: center;
    font-size: 6.2pt;
    color: #444;
    border-top: 0.4px solid #777;
    padding-top: 0.4mm;
    background: #fff;
  }

}
