* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #f3f4f6;
  color: #111827;
  font-family: Arial, sans-serif;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}

.login-view {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 18px;
}

.login-card {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 380px;
  padding: 20px;
  width: 100%;
}

.login-error {
  color: #b42318;
  font-size: 12px;
  min-height: 16px;
}

header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  margin: 0 0 4px;
}

p {
  margin: 0;
  color: #667085;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(560px, 1.2fr) minmax(420px, 0.8fr);
}

form {
  display: grid;
  gap: 10px;
}

.setup-panel {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}

.monitor-panel {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}

.monitoring-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  padding: 12px;
}

.monitor-metric {
  background: #f8fafc;
  border: 1px solid #e7ebf0;
  border-radius: 6px;
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 8px;
}

.monitor-metric small {
  color: #667085;
  font-size: 11px;
}

.monitor-metric strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.monitoring-alerts {
  border-top: 1px solid #e1e5eb;
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
}

.monitor-alert {
  border-radius: 6px;
  font-size: 12px;
  padding: 8px;
}

.monitor-alert.ok {
  background: #dcfce7;
  color: #166534;
}

.monitor-alert.warning {
  background: #fef3c7;
  color: #92400e;
}

.monitor-alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.setup-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.75fr);
  padding: 12px;
}

.setup-checks {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setup-check {
  align-items: start;
  background: #f8fafc;
  border: 1px solid #e7ebf0;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  min-height: 50px;
  padding: 8px;
}

.setup-check i {
  border-radius: 50%;
  flex: 0 0 9px;
  height: 9px;
  margin-top: 4px;
  width: 9px;
}

.setup-check.done i {
  background: #16a34a;
}

.setup-check.open i {
  background: #f59e0b;
}

.setup-check strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}

.setup-check small {
  color: #667085;
  display: block;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}

.setup-actions {
  display: grid;
  gap: 8px;
}

.ready {
  color: #15803d;
}

.open {
  color: #b45309;
}

.button-row {
  display: flex;
  gap: 8px;
}

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

.button-link {
  align-items: center;
  background: #111827;
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
}

.secondary-link {
  background: #ffffff;
  border: 1px solid #d4dae3;
  color: #111827;
  justify-content: center;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.process-strip {
  border-top: 1px solid #e1e5eb;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.process-step {
  border-right: 1px solid #e1e5eb;
  display: grid;
  gap: 3px;
  min-height: 92px;
  padding: 10px;
}

.process-step:last-child {
  border-right: 0;
}

.process-step b {
  align-items: center;
  background: #111827;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 11px;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.process-step strong {
  font-size: 12px;
  line-height: 1.2;
}

.process-step small {
  color: #667085;
  font-size: 11px;
  line-height: 1.35;
}

fieldset {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px;
}

.stack-panel {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  overflow: hidden;
}

legend {
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

label {
  color: #4b5563;
  display: grid;
  font-size: 12px;
  gap: 4px;
}

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

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

input {
  border: 1px solid #d4dae3;
  border-radius: 6px;
  color: #14171a;
  font: inherit;
  min-height: 32px;
  padding: 6px 8px;
}

select {
  border: 1px solid #d4dae3;
  border-radius: 6px;
  color: #14171a;
  font: inherit;
  min-height: 32px;
  padding: 6px 8px;
}

.rules-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 2px;
}

.rules-head strong {
  font-size: 12px;
}

.rule-table {
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  display: grid;
  overflow: hidden;
}

.rule-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(120px, 1.4fr) minmax(92px, 0.8fr) minmax(130px, 1fr) 64px 32px;
  padding: 6px;
}

.rule-row + .rule-row {
  border-top: 1px solid #eef1f5;
}

.rule-row-head {
  background: #f8fafc;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
  padding: 7px 8px;
}

.rule-row input,
.rule-row select {
  min-height: 30px;
  width: 100%;
}

.icon-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d4dae3;
  color: #667085;
  display: inline-flex;
  font-size: 18px;
  justify-content: center;
  min-height: 30px;
  padding: 0;
}

.icon-button:hover {
  border-color: #fca5a5;
  color: #b42318;
}

#lager-upload {
  background: #f8fafc;
  border-style: dashed;
  cursor: pointer;
  padding: 10px;
}

input::placeholder {
  color: #8a94a3;
}

input[type="color"] {
  padding: 3px;
}

button {
  background: #111827;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 0 14px;
}

button.secondary {
  background: #ffffff;
  border: 1px solid #d4dae3;
  color: #111827;
}

button.danger {
  background: #b42318;
}

.preview-panel {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  overflow: hidden;
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid #e1e5eb;
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
}

.panel-head.compact {
  padding: 8px 10px;
}

.panel-head span {
  color: #6b7280;
  font-size: 12px;
}

.status {
  background: #f8fafc;
  border: 1px solid #e1e5eb;
  border-radius: 6px;
  color: #3b424b;
  font-size: 12px;
  padding: 8px;
}

.checklist,
.offer-list {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.check-item,
.offer-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e7ebf0;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 30px;
  padding: 7px 8px;
}

.check-item {
  justify-content: flex-start;
}

.dot {
  border-radius: 50%;
  flex: 0 0 8px;
  height: 8px;
  width: 8px;
}

.dot.done {
  background: #16a34a;
}

.dot.open {
  background: #f59e0b;
}

.offer-main {
  display: grid;
  gap: 2px;
}

.run-item {
  cursor: pointer;
  font: inherit;
  text-align: left;
  width: 100%;
}

.run-item:hover {
  border-color: #9ca3af;
}

.offer-main strong,
.check-item span {
  font-size: 12px;
}

.offer-main small,
.offer-total {
  color: #667085;
  font-size: 11px;
}

.run-status {
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 7px;
}

.run-status.completed {
  background: #dcfce7;
  color: #166534;
}

.run-status.needs_review {
  background: #fef3c7;
  color: #92400e;
}

.run-status.failed_retryable,
.run-status.failed_terminal {
  background: #fee2e2;
  color: #991b1b;
}

iframe {
  background: #ffffff;
  border: 0;
  height: calc(100vh - 112px);
  min-height: 560px;
  width: 100%;
}

.run-detail {
  background: #ffffff;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  margin-top: 14px;
  overflow: hidden;
}

.run-detail-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.debug-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.debug-summary div,
.feedback-panel,
.debug-block {
  background: #f8fafc;
  border: 1px solid #e7ebf0;
  border-radius: 6px;
  padding: 8px;
}

.debug-summary small,
.feedback-panel small {
  color: #667085;
  display: block;
  font-size: 11px;
  line-height: 1.35;
}

.debug-summary strong {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.feedback-panel {
  display: grid;
  gap: 8px;
}

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

.debug-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.debug-block pre {
  background: #111827;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 11px;
  line-height: 1.45;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  white-space: pre-wrap;
}

.debug-draft {
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  overflow: hidden;
}

.debug-draft iframe {
  height: 520px;
  min-height: 520px;
}

@media (max-width: 980px) {
  header,
  .workspace,
  .setup-grid,
  .monitoring-grid,
  form,
  .inline,
  .inline.two,
  .debug-summary,
  .debug-grid {
    grid-template-columns: 1fr;
  }

  .setup-checks,
  .process-strip {
    grid-template-columns: 1fr;
  }

  .process-step {
    border-bottom: 1px solid #e1e5eb;
    border-right: 0;
  }

  header {
    align-items: stretch;
    display: grid;
  }

  iframe {
    height: 460px;
    min-height: 460px;
  }
}
