:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #66717f;
  --line: #d8dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --navy: #243b53;
  --warm: #b45309;
  --green: #166534;
  --shadow: 0 16px 44px rgba(21, 32, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

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

input,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

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

.tool-shell {
  width: min(1560px, calc(100vw - 26px));
  margin: 0 auto;
  padding: 16px 0 28px;
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.brand strong {
  display: block;
  font-size: 20px;
}

.eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions button {
  padding: 0 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
  padding-top: 18px;
}

.editor-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 14px;
}

.control-section {
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.template-button {
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 9px 10px;
  text-align: left;
}

.template-button.active {
  border-color: var(--accent);
  background: #e6f4f1;
}

.template-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title-row span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}

.product-list {
  display: grid;
  gap: 8px;
}

.product-choice {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.product-choice input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.product-choice strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
}

.product-choice small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.product-price {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.preview-panel {
  overflow: auto;
  padding: 20px;
}

.sales-sheet {
  width: min(100%, 980px);
  min-height: 1386px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #c9d2de;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(21, 32, 43, 0.16);
}

.sheet-inner {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 1386px;
  padding: 42px;
}

.sheet-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--ink);
}

.sheet-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sheet-brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
}

.sheet-kicker {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.sheet-brand h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
}

.sheet-status {
  padding: 8px 10px;
  border: 1px solid #f1c27d;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--warm);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.sheet-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 26px;
  padding: 30px 0 24px;
}

.sheet-hero h2 {
  margin: 0;
  font-size: 42px;
  line-height: 1.04;
  letter-spacing: 0;
}

.sheet-hero p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.facts {
  display: grid;
  gap: 10px;
}

.fact {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 20px;
}

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

.sheet-product {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sheet-visual {
  display: grid;
  place-items: center;
  min-height: 108px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0f766e, #243b53);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.sheet-product[data-family="elektrik"] .sheet-visual {
  background: linear-gradient(135deg, #243b53, #4f46e5);
}

.sheet-product[data-family="wasser"] .sheet-visual {
  background: linear-gradient(135deg, #0369a1, #0f766e);
}

.sheet-product[data-family="moebel"] .sheet-visual {
  background: linear-gradient(135deg, #3f6212, #166534);
}

.sheet-product h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.16;
}

.sheet-product p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 12px;
}

.sheet-product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.sheet-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}

.sales-box {
  padding: 16px;
  border-radius: 8px;
  background: #edf5f3;
}

.sales-box.alt {
  background: #f3f5f8;
}

.sales-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.sales-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.sales-box li + li {
  margin-top: 5px;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

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

.sheet-order-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .tool-shell {
    width: min(100vw - 16px, 1560px);
  }

  .tool-header,
  .sheet-top,
  .sheet-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .sheet-order-link {
    width: 100%;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1 1 160px;
  }

  .preview-panel {
    padding: 8px;
  }

  .sales-sheet {
    min-height: auto;
  }

  .sheet-inner {
    min-height: auto;
    padding: 20px;
  }

  .sheet-hero,
  .product-showcase,
  .sheet-bottom {
    grid-template-columns: 1fr;
  }

  .sheet-hero h2 {
    font-size: 30px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  .tool-header,
  .editor-panel {
    display: none !important;
  }

  .tool-shell,
  .workspace,
  .preview-panel {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .sales-sheet {
    width: 190mm;
    min-height: 277mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sheet-inner {
    min-height: 277mm;
    padding: 0;
  }

  .sheet-hero h2 {
    font-size: 34px;
  }

  .sheet-hero p {
    font-size: 15px;
  }

  .sheet-product {
    break-inside: avoid;
  }
}
