:root {
  --bg: #f4f6f8;
  --card: #fff;
  --accent: #1a6b3c;
  --accent-hover: #145530;
  --border: #d8dee4;
  --text: #1f2933;
  --muted: #5f6b7a;
  --error: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 { margin: 0 0 8px; font-size: 1.75rem; }

.lead { color: var(--muted); margin-bottom: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  overflow: visible;
}

.sku-card {
  overflow: visible;
}

.sku-card .grid {
  overflow: visible;
}

.card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.sku-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.btn-remove-sku {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--error);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.btn-remove-sku:hover {
  background: #fee4e2;
}

.btn-remove-sku[hidden] {
  display: none !important;
}

.num-input {
  text-align: right;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

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

.grid > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.grid label {
  margin-top: 0;
  min-height: 2.6em;
  line-height: 1.3;
}

.grid .span-2 { grid-column: span 2; }

.grid input,
.grid select {
  margin-bottom: 0;
}

.product-combobox-field {
  position: relative;
  z-index: 5;
}

.product-combobox {
  position: relative;
  z-index: 6;
}

.product-combobox input {
  margin-bottom: 0;
}

.product-suggestions {
  position: absolute;
  z-index: 1000;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.12);
}

.product-suggestion {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.product-suggestion:hover,
.product-suggestion.is-active {
  background: #eff6fc;
}

.product-suggestion-name {
  flex: 1;
  min-width: 0;
}

.product-suggestion-plu {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.catalog-status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.catalog-status-warn {
  background: #fff8e6;
  color: #8a6100;
  border: 1px solid #f5d98e;
  cursor: pointer;
}

select.cell-input {
  margin-bottom: 0;
}

.form-actions-wrap {
  margin: 8px 0 20px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.add-sku-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.main-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-add-sku,
.btn-toggle-outlook,
.btn-create-excel {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-add-sku {
  background: #fff;
  color: var(--accent);
  border: 2px dashed var(--accent);
  min-width: 180px;
  width: auto;
}

.btn-add-sku:hover {
  background: #f0fdf4;
}

.btn-create-excel {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-create-excel:hover {
  background: var(--accent-hover);
}

.btn-toggle-outlook {
  background: #fff;
  color: #0078d4;
  border: 2px solid #0078d4;
}

.btn-toggle-outlook:hover,
.btn-toggle-outlook.is-active {
  background: #eff6fc;
}

.form-actions-hint {
  margin: 10px 0 0;
  text-align: center;
}

.mail-card[hidden] {
  display: none !important;
}

.mail-card .btn-outlook {
  width: 100%;
  margin-top: 4px;
}

.mail-hint {
  margin-top: 10px;
  margin-bottom: 0;
}

.btn-outlook {
  background: #fff;
  color: #0078d4;
  border: 2px solid #0078d4;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-outlook:hover {
  background: #eff6fc;
}

.btn-outlook:disabled {
  opacity: 0.6;
  cursor: wait;
}

.mail-card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 12px;
  font-family: inherit;
  resize: vertical;
}

.error {
  background: #fef3f2;
  color: var(--error);
  border: 1px solid #fecdca;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.dates-row {
  margin-top: 12px;
}

.sku-extra-row {
  margin-top: 12px;
}

.price-block,
.shipment-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.calc-block {
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  background: #edf7ed;
  border: 1px solid #c8e6c9;
}

.calc-turnover-row {
  margin-top: 12px;
}

.calc-field {
  background: #f4fbf4;
  color: var(--text);
  cursor: default;
  text-align: right;
}

.calc-field:focus {
  outline: none;
  border-color: var(--border);
}

.x5-macro-row {
  margin-top: 12px;
}

.x5-only {
  margin-top: 0;
}

input[type="date"] {
  cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.x5-only[hidden] {
  display: none !important;
}

.listing-only[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .main-actions {
    grid-template-columns: 1fr;
  }

  .btn-add-sku {
    width: 100%;
  }

  .grid .span-2 { grid-column: span 1; }
}
