:root {
  --bg: #eef2f5;
  --card: #ffffff;
  --ink: #16212c;
  --muted: #5e6a74;
  --line: #d5dde5;
  --accent: #253f9f;
  --accent-soft: #e4e9ff;
  --warn: #7a4a0d;
  --warn-soft: #fff1de;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #dceaf1 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, #e8f3ea 0%, transparent 40%),
    var(--bg);
  min-height: 100vh;
  padding: 24px;
  caret-color: transparent;
  cursor: default;
}

input,
textarea,
select {
  caret-color: auto;
  cursor: text;
}

button,
label,
.chip,
.tool-btn {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 720px) 300px;
  gap: 18px;
  justify-content: center;
  align-items: start;
}

.app-main { min-width: 0; }

.top-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tool-btn {
  width: auto;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: #f7fafc;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

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

.step {
  border: 1px solid var(--line);
  background: #f7fafc;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.step span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e7edf3;
}

.step.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #9cc9cf;
}

.step.active span {
  background: var(--accent);
  color: #fff;
}

.container {
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  border: 1px solid #e6edf2;
  box-shadow: 0 10px 26px rgba(17, 34, 51, 0.08);
}

.hidden { display: none; }
.center { text-align: center; }

h2 { margin: 0 0 8px; }
.subtitle { margin: 0 0 10px; color: var(--muted); }

label { display: block; margin-top: 14px; font-weight: 600; }

input, select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  background: #fff;
}

.readonly-field {
  background: #edf2f6;
  color: #56606a;
}

.checkbox-group { margin-top: 6px; }
.chip-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  cursor: pointer;
  position: relative;
  overflow: visible;
}

.chip input { width: auto; margin: 0; }
.chip input[type="checkbox"] { cursor: pointer; }
.mobile-chip-input { cursor: text !important; }

.mobile-lines-inline {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}

.mobile-chip-input {
  width: 52px !important;
  min-width: 52px;
  margin: 0 !important;
  padding: 4px 6px !important;
  border-radius: 6px;
  text-align: center;
}

.chip:has(input:checked) {
  border-color: #8bbec5;
  background: var(--accent-soft);
}

.chip-warning:has(input:checked) {
  border-color: #d8ad77;
  background: var(--warn-soft);
}

.is-invalid {
  border-color: #c62828 !important;
  box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.14);
}

.chip.is-invalid {
  background: #fff5f5 !important;
}

.inline-buttons.is-invalid {
  padding: 6px;
  border: 1px solid #c62828;
  border-radius: 10px;
}

.validation-tooltip {
  margin-top: 6px;
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: #c62828;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  position: relative;
}

.validation-tooltip::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 12px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #c62828;
}

.validation-tooltip-floating {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin-top: 0;
}

button {
  width: 100%;
  margin-top: 14px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid #1d3488;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inline-buttons { display: flex; gap: 8px; margin-top: 8px; }
.inline-buttons button { width: auto; flex: 1; margin-top: 0; }
.choice-active { background: #1d3488; border-color: #172a6d; }

.info-text {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field-hint {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff3e6;
  color: #8b5a1d;
  border: 1px solid #f0d1a8;
  font-size: 13px;
}

.status {
  margin-top: 10px;
  font-weight: 600;
  text-align: center;
  min-height: 20px;
}

.preview-box {
  margin-top: 6px;
  border: 1px dashed #b6c4cf;
  background: #f9fcff;
  border-radius: 10px;
  padding: 10px;
  min-height: 120px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.4;
}

.summary-rail {
  position: sticky;
  top: 18px;
  border-radius: 14px;
  border: 1px solid #dbe4ec;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(17, 34, 51, 0.07);
  padding: 16px;
}

.summary-rail h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid #edf2f7;
}

.summary-item:first-of-type { border-top: 0; }
.summary-item span { color: var(--muted); font-size: 12px; }
.summary-item strong {
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

#sumSalesIdRow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-link {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  font-size: 12px;
  font-weight: 600;
}

.inline-link:hover {
  color: #1d3488;
}

.footer-note {
  margin-top: 18px;
  font-size: 12px;
  color: #66717a;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .summary-rail {
    position: static;
  }
}

@media (max-width: 640px) {
  body { padding: 14px; }
  .chip-group { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: 1fr; }
}
