:root {
  --bg: #0f1c1f;
  --panel: #122429;
  --panel-2: #162f35;
  --accent: #ffb347;
  --accent-2: #7ef9ff;
  --text: #e9f2f1;
  --muted: #a8c0bf;
  --danger: #ff7b7b;
  --good: #8bffb6;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, rgba(126, 249, 255, 0.12), transparent 50%),
    radial-gradient(circle at 80% 0%, rgba(255, 179, 71, 0.2), transparent 40%),
    linear-gradient(160deg, #0b1416, #0f1c1f 45%, #102226);
  min-height: 100vh;
  padding: 32px;
}

.app {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -0.02em;
}

header p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 520px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  color: var(--accent-2);
  background: rgba(126, 249, 255, 0.12);
  border: 1px solid rgba(126, 249, 255, 0.4);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.form-area {
  width: 100%;
}

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

.address-grid .field {
  margin-bottom: 0;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-field label {
  margin: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.req-star {
  color: #ff4d4f;
  margin-right: 4px;
  font-weight: 700;
}

input,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
  transition: border 0.2s ease;
}

input:focus,
textarea:focus {
  border-color: rgba(126, 249, 255, 0.6);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.row-compact-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.row-compact-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.address-row {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 10px;
  align-items: stretch;
}

.picker-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  align-items: stretch;
}

.preset-wrap {
  display: grid;
  grid-template-columns: 1fr 28px;
  gap: 6px;
  align-items: stretch;
  height: 100%;
}

.preset-delete-btn {
  width: 28px;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border-radius: 0 12px 12px 0;
  border: 1px solid rgba(255, 123, 123, 0.8);
  background: rgba(255, 123, 123, 0.16);
  color: #ffd2d2;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.preset-delete-btn.show {
  display: inline-flex;
}

.import-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  align-items: stretch;
}

.import-area {
  width: min(640px, 100%);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head label {
  margin: 0;
}

.result-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.result-actions button {
  padding: 8px 14px;
  font-size: 13px;
}

#startBtn {
  color: #fff6f6;
  background: linear-gradient(135deg, #ff5c5c, #ff8f3f);
  box-shadow: 0 12px 28px rgba(255, 92, 92, 0.4);
}

@media (max-width: 1080px) {
  .row-compact-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .row-compact-5 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .address-grid {
    grid-template-columns: 1fr;
  }

  .picker-row {
    grid-template-columns: 240px 1fr;
  }
}

select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 13px;
  padding: 8px;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

.picker-select {
  border: 2px solid var(--danger);
  background: rgba(255, 123, 123, 0.08);
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 12px;
}

.picker-input {
  border: 2px solid var(--accent-2);
  border-radius: 0 12px 12px 0;
}

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

button {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  color: #0d1517;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(255, 179, 71, 0.3);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.status {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.log,
.output {
  background: #0c171a;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  resize: vertical;
}

.output {
  max-height: 1024px;
  resize: vertical;
  overflow: auto;
}

.page-block {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(18, 36, 41, 0.6);
}

.page-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--accent-2);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.log-line {
  color: var(--muted);
}

.log-line strong {
  color: var(--accent-2);
}

.log-line.error {
  color: var(--danger);
}

.log-line.good {
  color: var(--good);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}

.copy-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: none;
}

.row-danger {
  background: rgba(255, 123, 123, 0.12);
}

.chain-pill {
  display: inline-flex;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(126, 249, 255, 0.12);
  color: var(--accent-2);
  width: fit-content;
}

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.footer-bar a {
  color: var(--accent-2);
  text-decoration: none;
}

.footer-bar a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  body {
    padding: 20px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
