/* ── Create view ───────────────────────────────────────────────────────────── */

.create-outer {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}

.create-form {
  flex: 1;
  min-width: 0;
}

/* Live preview pane */
.create-preview-pane {
  width: 680px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-height) + var(--space-4));
  max-height: calc(100vh - var(--nav-height) - var(--space-8));
  overflow-y: auto;
}

.create-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.create-preview-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.create-preview-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.create-preview-actions .select-sm,
.create-preview-actions .btn-sm {
  height: 1.75rem;
  line-height: 1;
}

.create-preview-pane .invoice-paper {
  padding: var(--space-6);
}

.create-aside {
  margin-top: var(--space-4);
}

.create-action-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--bg-base);
}

.create-action-box .create-aside-row {
  margin-bottom: var(--space-3);
}

.create-action-box .btn-full {
  margin-bottom: 0;
}

.create-aside-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.select-sm {
  width: auto;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  height: 1.75rem;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text);
}

.validate-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  margin: 0;
  height: 1.75rem;
}

/* Pipeline checklist */
.pipeline-steps {
  list-style: none;
  padding: var(--space-3) 0 0 0;
  margin: var(--space-3) 0 0 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.pipeline-step {
  padding: var(--space-1) 0 var(--space-1) var(--space-5);
  position: relative;
  color: var(--text-secondary);
}

.pipeline-step::before {
  position: absolute;
  left: 0;
  width: 1.2em;
  text-align: center;
}

.pipeline-step--active::before { content: "\29D7"; color: var(--text-muted); }
.pipeline-step--done::before   { content: "\2713"; color: var(--success); }
.pipeline-step--done           { color: var(--text); }
.pipeline-step--error::before  { content: "\2717"; color: var(--error); }
.pipeline-step--error          { color: var(--error); }

/* Line items */
.line-items-header,
.line-item-row {
  display: grid;
  grid-template-columns: 3fr 1.1fr 1.6fr 1.4fr 1.1fr 1.5fr auto;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.line-items-header {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}

.line-item-row input,
.line-item-row select {
  margin-bottom: 0;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
}

.li-total {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
}

/* Totals */
.totals-summary {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-1) 0;
  color: var(--text-secondary);
}

.totals-row.grand-total {
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  font-size: var(--text-base);
}

/* JSON preview (resizable) */
.json-preview-resizable {
  resize: vertical;
  overflow: hidden;
  min-height: 8rem;
  max-height: 80vh;
  height: 24rem;
}

.json-preview-resizable .code-preview {
  height: 100%;
  max-height: none;
  border: none;
  border-radius: 0;
  padding: var(--space-3);
}

/* Code preview */
.code-preview {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: 0;
  max-height: 38vh;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
  color: var(--text);
}

/* XML syntax */
.xml-pi      { color: #c084fc; }
.xml-comment { color: var(--text-muted); font-style: italic; }
.xml-punct   { color: var(--text-secondary); }
.xml-tagname { color: var(--success); font-weight: 500; }
.xml-attr    { color: #c084fc; }
.xml-string  { color: var(--primary-light); }

@media (max-width: 1024px) {
  .create-outer {
    flex-direction: column;
  }
  .create-preview-pane {
    width: 100%;
    position: static;
    max-height: none;
  }
}
