:root {
  color-scheme: light;
  --ink: #18211d;
  --muted: #66746d;
  --line: #d4ddd7;
  --paper: #f5f6f2;
  --panel: #ffffff;
  --accent: #23714f;
  --accent-dark: #154932;
  --amber: #b9782e;
  --danger: #9f3b34;
  --shadow: 0 18px 45px rgba(24, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

.store-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 22px;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.1;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-metrics span,
#orderIdPreview {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfa;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(360px, 1fr) minmax(280px, 360px);
  min-height: 0;
  overflow: hidden;
}

.catalog-panel,
.sheet-panel,
.order-panel {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  overflow: auto;
}

.sheet-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  background: #eef2ec;
}

.order-panel {
  border-right: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 15px;
}

.catalog-grid,
.category-tabs,
.line-items,
.order-form {
  display: grid;
  gap: 10px;
}

.category-tabs {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  margin-bottom: 12px;
}

.category-tab {
  min-height: 34px;
  border-color: var(--line);
  background: #fbfcfa;
  color: var(--muted);
}

.category-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.product-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 8px;
}

.product-art {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid #e0e7e2;
  border-radius: 7px;
  background: #fff;
}

.product-art img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.product-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.product-meta strong,
.line-item strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.product-meta span,
.line-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-meta .category-label {
  color: var(--amber);
}

.stepper {
  display: grid;
  grid-template-columns: 32px 32px 32px;
  align-items: center;
  gap: 4px;
}

.stepper output {
  color: var(--ink);
  text-align: center;
  font-weight: 900;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #234237;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1;
}

.text-action,
.secondary-action {
  border-color: #d7ab72;
  background: #fff8ec;
  color: #744915;
}

.text-action {
  min-height: 32px;
  padding: 0 10px;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
}

.sheet-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe7e2;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#sheetSvg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: transparent;
}

.sheet-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sheet-status strong {
  color: var(--ink);
}

.sheet-status.over strong,
.topbar-metrics .over {
  color: var(--danger);
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.line-item:last-child {
  border-bottom: 0;
}

.line-item em {
  color: var(--ink);
  font-style: normal;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed #aebbb3;
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

#orderMessage {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(270px, 370px) minmax(360px, 1fr);
  }

  .order-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
    overflow: visible;
  }

  .store-shell {
    height: auto;
    overflow: visible;
  }

  .catalog-panel,
  .sheet-panel,
  .order-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sheet-panel {
    min-height: 680px;
  }

  .sheet-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .catalog-panel,
  .sheet-panel,
  .order-panel,
  .topbar {
    padding: 14px;
  }

  .product-card {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .product-art {
    width: 58px;
    height: 58px;
  }

  .product-art img {
    width: 50px;
    height: 50px;
  }

  .stepper {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
