:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647084;
  --line: #d9e0ea;
  --paper: #ffffff;
  --wash: #f4f7f9;
  --teal: #087c78;
  --teal-soft: #e4f5f3;
  --amber: #b66d00;
  --amber-soft: #fff3d7;
  --accent: #315c9c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--wash);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 86px;
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 10px clamp(14px, 4vw, 36px);
  background: #078fd0;
  color: white;
  box-shadow: 0 2px 16px rgba(0, 89, 140, .24);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 34px;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, .34);
  color: white;
  white-space: nowrap;
}

.gear-mark {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.gear-name {
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 900;
  letter-spacing: .03em;
}

.brand {
  margin: 0 0 2px;
  color: #dff7ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: clamp(17px, 2.6vw, 24px);
}

.status {
  flex: 0 0 auto;
  color: #e8f8ff;
  font-size: 12px;
  text-align: right;
}

.shell {
  width: min(1040px, calc(100% - 24px));
  margin: 18px auto;
}

.hidden { display: none !important; }

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 13px 14px;
  line-height: 1.7;
}

.favorite-notice {
  background: var(--amber-soft);
  border-color: #f0c36d;
  margin-bottom: 14px;
}

.favorite-notice strong {
  display: block;
  color: #7a4600;
  margin-bottom: 3px;
}

.help-panel {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.help-panel summary,
.optional-fields summary {
  cursor: pointer;
  padding: 11px 13px;
  font-weight: 850;
  color: var(--accent);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 13px 13px;
}

.help-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.help-grid b {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.help-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.error {
  border-color: #e89b9b;
  background: #fff0f0;
  color: #8c1f1f;
}

.customer-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label span {
  display: inline-block;
  margin-left: 4px;
  color: #8a96a8;
  font-size: 11px;
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  color: var(--ink);
}

input[readonly] {
  background: #f8fafc;
  color: #334155;
  font-weight: 800;
}

textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }

.optional-fields {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.tools {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  margin: 12px 0;
}

.tools button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 2px 8px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.category-block {
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.category-block.empty-cat {
  display: none;
}

.category-block.collapsed .category-body {
  display: none;
}

.category-block.collapsed .chevron {
  transform: rotate(-90deg);
}

.category-title {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--teal-soft);
  color: #075f5d;
  text-align: left;
}

.category-title:hover {
  background: #d8efec;
}

.chevron {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  transition: transform .16s ease;
  font-weight: 900;
}

.category-title h3 {
  flex: 1 1 auto;
  margin: 0;
  font-size: 15px;
}

.category-title span {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 850;
}

.category-body {
  padding: 10px;
}

.cat-input-badge {
  display: none;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #0f9f6e;
  color: white;
  font-size: 12px;
  font-weight: 850;
}

.cat-has-input .cat-input-badge {
  display: inline-flex;
  gap: 2px;
}

.count-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  background: white;
  font-size: 12px;
  font-weight: 800;
}

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

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.card.favorite {
  border-color: #e5b84e;
  box-shadow: inset 3px 0 0 #e5b84e;
}

.card.has-qty {
  border-color: #10a57d;
  background: #f3fffb;
  box-shadow: inset 3px 0 0 #10a57d;
}

.item-card.hidden-search {
  display: none;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.product-name {
  font-size: 15px;
  font-weight: 850;
  line-height: 1.45;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.favorite-button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 7px 9px;
  color: #7a4600;
}

.favorite-button.on {
  border-color: #e5b84e;
  background: var(--amber-soft);
}

.qty-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  align-items: center;
  gap: 8px;
}

.item-details {
  border-top: 1px dashed var(--line);
  padding-top: 2px;
}

.item-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.item-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.item-detail-grid textarea {
  grid-column: 1 / -1;
}

.item-detail-grid input,
.item-detail-grid textarea {
  padding: 8px;
  font-size: 13px;
}

.variant-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 7px;
}

.variant {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: center;
  padding: 7px;
  border-radius: 8px;
  background: #f8fafc;
}

.variant input {
  width: 100%;
  text-align: center;
}

.variant.has-qty {
  background: #e9fbf4;
  outline: 1px solid #10a57d;
}

.price {
  color: var(--teal);
  font-weight: 850;
}

.proposal-band {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #efd0a7;
  border-radius: 8px;
  background: #fff8ec;
}

.proposal-card {
  background: white;
  border-color: #efd0a7;
}

.proposal-reason,
.proposal-note {
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 13px;
  line-height: 1.55;
}

.proposal-reason {
  background: #eef8ff;
  color: #075985;
}

.proposal-note {
  background: #fff7e6;
  color: #7a4600;
  font-weight: 800;
}

.proposal-card img,
.proposal-image {
  width: 100%;
  height: clamp(120px, 18vw, 180px);
  object-fit: contain;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #eef2f6;
}

.summary {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 36px);
  background: white;
  border-top: 2px solid var(--teal);
  box-shadow: 0 -8px 24px rgba(23, 32, 51, .12);
}

.summary strong {
  margin-left: 12px;
  color: var(--teal);
}

#confirmButton, #copyOrderText {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

dialog {
  width: min(760px, calc(100% - 20px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(23, 32, 51, .35);
}

dialog::backdrop {
  background: rgba(23, 32, 51, .62);
}

.dialog-head, .dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 14px;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.7;
}

@media (max-width: 760px) {
  .customer-form, .product-grid, .proposal-grid, .help-grid, .optional-grid {
    grid-template-columns: 1fr;
  }
  .item-detail-grid {
    grid-template-columns: 1fr;
  }
  .tools {
    grid-template-columns: 1fr 86px 86px;
  }
  .tools button:nth-of-type(n+3) {
    grid-column: span 1;
  }
  .topbar {
    align-items: flex-start;
  }
  .brand-block {
    gap: 10px;
  }
  .brand-logo {
    gap: 6px;
    padding-right: 8px;
  }
  .gear-mark {
    width: 28px;
    height: 28px;
  }
  .gear-name {
    font-size: 16px;
  }
  .status {
    max-width: 120px;
  }
}
