* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f7f8fa;
  color: #1b1f23;
}

.home-main {
  max-width: 900px;
  margin: 60px auto;
  padding: 0 24px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.home-card {
  display: block;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 28px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.home-card:hover {
  border-color: #2a9d8f;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.home-card-title {
  font-size: 20px;
  font-weight: 700;
  color: #1d3557;
  margin-bottom: 10px;
}

.home-card-desc {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #1d3557;
  color: white;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: white;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.9;
}

.nav-link:hover {
  text-decoration: underline;
}

.upload-btn {
  background: #2a9d8f;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.upload-btn:hover {
  background: #248a7e;
}

.flash-wrap {
  padding: 12px 24px 0;
}

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
}

.flash-success {
  background: #d4f4dd;
  color: #155724;
}

.flash-error {
  background: #fde2e2;
  color: #842029;
}

.meta-bar {
  display: flex;
  gap: 16px;
  padding: 10px 24px;
  font-size: 13px;
  color: #555;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.search-wrap {
  position: relative;
  margin-bottom: 16px;
}

#search-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  outline: none;
  background: white;
}

#search-input:focus {
  border-color: #2a9d8f;
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
}

.suggest-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  z-index: 10;
  max-height: 320px;
  overflow-y: auto;
}

.suggest-box.hidden {
  display: none;
}

.suggest-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.suggest-item:hover, .suggest-item.active {
  background: #f0f7f6;
}

.suggest-type {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  align-self: center;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chips.hidden {
  display: none;
}

.tag-chip {
  border: 1px solid #d0d5dd;
  background: white;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #444;
  transition: all 0.12s;
}

.tag-chip:hover {
  border-color: #2a9d8f;
}

.tag-chip.selected {
  background: #2a9d8f;
  color: white;
  border-color: #2a9d8f;
}

.category-filter-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.category-filter-section.hidden {
  display: none;
}

.category-filter-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

#new-items-date {
  padding: 5px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.tags-label {
  font-size: 13px;
  color: #666;
  font-weight: 600;
}

.clear-tags {
  border: none;
  background: none;
  color: #e63946;
  font-size: 13px;
  cursor: pointer;
}

.search-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 0;
}

.match-any-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
  margin-bottom: 12px;
}

.match-any-toggle input {
  cursor: pointer;
}

.column-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.column-preset-btn {
  border: 1px solid #2a9d8f;
  background: white;
  color: #2a9d8f;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.column-preset-btn:hover {
  background: #2a9d8f;
  color: white;
}

.export-btn {
  margin-left: auto;
  border-color: #1d3557;
  color: #1d3557;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.export-btn:hover {
  background: #1d3557;
  color: white;
}

.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2a9d8f;
  color: white;
  border-radius: 14px;
  padding: 5px 8px 5px 12px;
  font-size: 13px;
}

.term-chip-remove {
  border: none;
  background: none;
  color: white;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}

.active-filters {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
  min-height: 18px;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.column-toggles.hidden {
  display: none;
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
  white-space: nowrap;
}

.column-toggle input {
  cursor: pointer;
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.customer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.customer-bar select {
  padding: 7px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  min-width: 220px;
}

.customer-input-wrap {
  position: relative;
}

#customer-input {
  padding: 7px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  min-width: 240px;
}

#customer-input.input-invalid {
  border-color: #e63946;
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.12);
}

#customer-suggest-box {
  width: 240px;
}

.new-customer-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.new-customer-fields input {
  padding: 7px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  min-width: 160px;
}

.order-cart-title {
  font-size: 18px;
  font-weight: 700;
  color: #1d3557;
  margin: 28px 0 12px;
}

#order-cart-table th,
#order-cart-table td {
  border: 1px solid #e5e7eb;
}

#order-cart-body tr:nth-child(even) {
  background: #f7f9fa;
}

.order-cart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 14px 16px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.order-cart-total {
  font-size: 16px;
  font-weight: 700;
  color: #1d3557;
}

.cart-qty-input, .cart-price-input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  text-align: center;
}

.cart-remove-btn {
  color: #e63946;
  font-size: 18px;
}

.order-actions {
  display: flex;
  gap: 6px;
}

.selection-count {
  font-size: 13px;
  color: #555;
  font-weight: 500;
}

.col-select {
  width: 36px;
  text-align: center;
}

.col-select input {
  cursor: pointer;
}

.results {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: auto;
  max-height: 75vh;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.product-table thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  font-weight: 600;
  padding: 10px 14px;
  background: #f7f8fa;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 0 #e5e7eb;
  z-index: 5;
}

.product-row td {
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f2;
  vertical-align: middle;
}

.product-row:last-child td {
  border-bottom: none;
}

.product-row:nth-child(even) {
  background: #f7f9fa;
}

.product-row:hover {
  background: #eef6f5;
}

.col-img {
  width: 56px;
}

.col-img a {
  display: block;
  width: 48px;
  height: 48px;
  position: relative;
}

.col-img img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 6px;
  background: #f2f3f5;
  display: block;
  position: relative;
  transition: transform 0.15s ease;
}

.col-img a:hover img {
  transform: scale(4.5);
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.product-item-number {
  font-weight: 700;
  color: #2a9d8f;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.product-description {
  font-weight: 600;
  line-height: 1.3;
}

.product-sub {
  color: #666;
  white-space: nowrap;
}

.product-prices {
  color: #333;
  white-space: nowrap;
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}

.product-tag {
  font-size: 11px;
  background: #f0f1f3;
  color: #555;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: #888;
  padding: 60px 0;
}

.product-description {
  cursor: pointer;
}

.order-writing-page .product-description {
  max-width: 200px;
  overflow-wrap: break-word;
}

.order-writing-page .product-item-number {
  max-width: 120px;
  white-space: normal;
  overflow-wrap: break-word;
}

.order-writing-page #results {
  max-height: 220px;
}

.value-from-notes {
  color: #e63946;
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: white;
  border-radius: 10px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #666;
}

#notes-modal-title {
  margin: 0 0 12px;
  font-size: 16px;
  padding-right: 24px;
}

#notes-modal-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: #333;
  margin: 0;
}

.results .product-row[data-notes] {
  cursor: pointer;
}

.order-cube-intro {
  font-size: 14px;
  color: #555;
  max-width: 720px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.order-upload-form {
  margin-bottom: 20px;
}

.max-hi-input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.max-hi-input:focus {
  border-color: #2a9d8f;
  outline: none;
}

.order-upload-form .upload-btn {
  background: #1d3557;
}

.order-upload-form .upload-btn:hover {
  background: #16284a;
}

.order-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.order-summary-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 160px;
}

.order-summary-card.highlight {
  border-color: #2a9d8f;
  background: #f0f9f8;
}

.order-summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 4px;
}

.order-summary-value {
  font-size: 24px;
  font-weight: 700;
  color: #1d3557;
}

.order-line-unmatched {
  background: #fff7ed;
}

.order-line-flag {
  font-size: 11px;
  color: #b54708;
  background: #ffedd5;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 6px;
}
