:root {
  --orange: #ff7900;
  --ink: #24272b;
  --muted: #68707a;
  --line: #dfe3e8;
  --soft: #f5f6f8;
  --panel: #ffffff;
  --dark: #2d3034;
  --danger: #b42318;
  --success: #166534;
  --focus: rgba(255, 121, 0, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  background: #eef0f2;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f1f2f4;
}

.login-panel {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-top: 5px solid var(--orange);
  padding: 34px;
  box-shadow: 0 18px 48px rgba(36, 39, 43, 0.12);
}

.login-logo {
  width: 168px;
  display: block;
  height: auto;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0 0 10px;
  font-size: 27px;
  line-height: 1.15;
}

.login-copy {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 14px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
}

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

.brand img {
  width: 96px;
  height: auto;
  flex: 0 0 auto;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.header-nav {
  display: flex;
  gap: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 4px;
}

.header-nav a {
  text-decoration: none;
  color: #4d545c;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
}

.header-nav a:hover {
  background: #fff;
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 42vw);
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.editor {
  display: grid;
  gap: 14px;
}

.panel,
.report-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
}

.hero-editor {
  border-top: 4px solid var(--orange);
}

.section-title {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-title > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--dark);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.section-title h2 {
  margin: 0 0 3px;
  font-size: 19px;
  line-height: 1.2;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
}

.field > span,
.details-editor > span {
  color: #4a5159;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd5dc;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  border-radius: 0;
}

textarea {
  min-height: 94px;
  resize: vertical;
  line-height: 1.5;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #5d646d 50%), linear-gradient(135deg, #5d646d 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--focus);
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-new-block,
.icon-button,
.recipient-meta button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--orange);
  color: #111;
}

.btn-secondary,
.btn-ghost,
.icon-button,
.recipient-meta button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn-new-block {
  background: var(--dark);
  color: #fff;
}

.btn-primary:hover,
.btn-new-block:hover {
  filter: brightness(0.96);
}

.btn-secondary:hover,
.btn-ghost:hover,
.icon-button:hover,
.recipient-meta button:hover {
  border-color: #aeb5bd;
  background: #f8f9fa;
}

.new-block-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.blocks-container {
  display: grid;
  gap: 12px;
}

.content-block {
  border: 1px solid var(--line);
  background: #fff;
}

.block-head {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
}

.block-head strong,
.block-head span {
  display: block;
}

.block-head strong {
  font-size: 13px;
}

.block-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.block-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4a5159;
  font-size: 13px;
  font-weight: 700;
}

.toggle input,
.option-row input {
  width: auto;
  accent-color: var(--orange);
}

.details-editor {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 8px;
}

.empty-state {
  border: 1px dashed #b8c0c8;
  background: #fafbfc;
  padding: 18px;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
  margin-bottom: 4px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.option-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #4f5660;
}

.delivery-note {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
  align-self: end;
  min-height: 65px;
}

.delivery-note strong,
.delivery-note span {
  display: block;
}

.delivery-note strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.delivery-note span {
  color: var(--muted);
  margin-top: 5px;
  font-size: 13px;
}

#recipients {
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  min-height: 150px;
}

.recipient-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

#recipientCount {
  min-width: 28px;
  text-align: center;
  padding: 4px 8px;
  background: var(--dark);
  color: #fff;
  font-weight: 700;
}

.actions {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: rgba(238, 240, 242, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.actions button {
  flex: 1 1 132px;
}

.preview {
  position: sticky;
  top: 94px;
  background: var(--dark);
  border: 1px solid #1f2124;
}

.preview-toolbar {
  min-height: 58px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.preview-toolbar strong,
.preview-toolbar span {
  display: block;
}

.preview-toolbar span {
  color: #c8ccd1;
  font-size: 12px;
  margin-top: 2px;
}

.preview-tabs {
  display: flex;
  gap: 6px;
}

.tab {
  min-height: 32px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #c8ccd1;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.tab.active {
  background: var(--orange);
  color: #111;
  border-color: var(--orange);
  font-weight: 700;
}

.preview-pane {
  display: none;
}

.preview-pane.active {
  display: block;
}

.preview iframe,
#previewTextContent {
  display: block;
  width: 100%;
  height: calc(100vh - 172px);
  min-height: 560px;
  border: 0;
}

.preview iframe {
  background: #fff;
}

#previewTextContent {
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #e4e7eb;
  background: #23262a;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.alert {
  padding: 12px 14px;
  border: 1px solid;
  background: #fff;
  line-height: 1.45;
}

.alert.success {
  color: var(--success);
  background: #f0fdf4;
  border-color: #86efac;
}

.alert.error {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.report-card {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.report-card strong {
  flex-basis: 100%;
}

.report-card span {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.report-card details {
  flex-basis: 100%;
  font-size: 13px;
}

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

  .preview {
    position: static;
  }
}

@media (max-width: 760px) {
  .header-inner {
    grid-template-columns: 1fr auto;
    padding: 12px;
  }

  .header-nav {
    grid-column: 1 / -1;
    order: 3;
    overflow-x: auto;
  }

  .brand img {
    width: 80px;
  }

  .workspace {
    padding: 10px;
  }

  .panel {
    padding: 16px;
  }

  .grid.two,
  .detail-row,
  .block-head {
    grid-template-columns: 1fr;
  }

  .actions button {
    flex-basis: 100%;
  }
}
