:root {
  --bg: #f3f6fb;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --surface-muted: #f7f9fc;
  --line: #d9e2f0;
  --line-strong: #b9c8dc;
  --text: #122033;
  --muted: #62718a;
  --accent: #2f6fed;
  --accent-dark: #1f57c7;
  --accent-soft: #eaf1ff;
  --danger-soft: #fce7e7;
  --shadow: 0 18px 48px rgba(28, 53, 94, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(47, 111, 237, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(44, 196, 182, 0.12), transparent 22%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
  min-height: 100vh;
}

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

.page-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.48fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  color: var(--accent-dark);
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 0.96;
  max-width: 12ch;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.hero-card,
.panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
}

.hero-card {
  border-radius: var(--radius-xl);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.metric {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #f9fbff 0%, #eff4fb 100%);
  border: 1px solid var(--line);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.workspace {
  display: block;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2,
.section-title h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-heading p,
.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.required-mark {
  color: #d92d20;
  font-weight: 700;
  display: inline-block;
  margin-left: 4px;
  font-size: 0.9em;
}

.section-block + .section-block {
  margin-top: 16px;
}

.section-block {
  position: relative;
  padding: 16px 16px 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(247, 250, 255, 0.82) 100%);
  border: 1px solid rgba(185, 200, 220, 0.55);
  box-shadow: 0 8px 22px rgba(28, 53, 94, 0.06);
}

.section-block::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 20px 0 0 20px;
  background: linear-gradient(180deg, var(--accent) 0%, #7aa4ff 100%);
}

.section-title {
  margin-bottom: 12px;
  padding-left: 4px;
}

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

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

.agency-grid {
  grid-template-columns: 0.9fr 1.3fr 1.2fr 1.2fr 1.2fr 1.2fr;
}

.compact-section {
  padding-block: 14px;
}

.top-meta-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

.station-grid label:nth-child(1) {
  grid-column: 1 / span 7;
  grid-row: 1;
}

.station-grid label:nth-child(2),
.station-grid label:nth-child(3),
.station-grid label:nth-child(4),
.station-grid label:nth-child(5) {
  grid-column: span 5;
  grid-row: 1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0;
}

label:has(input[required]),
label:has(select[required]) {
  color: #d92d20;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(47, 111, 237, 0.5);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.14);
}

input[readonly] {
  background: var(--surface-muted);
  color: var(--muted);
}

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

.full-span {
  grid-column: 1 / -1;
}

.items-list {
  display: grid;
  gap: 14px;
}

.item-card {
  border: 1px solid rgba(185, 200, 220, 0.7);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(252, 253, 255, 0.98) 0%, rgba(243, 247, 253, 0.94) 100%);
  padding: 14px;
}

.item-card-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.item-grid {
  grid-template-columns: 1fr 1fr 1fr 0.95fr 2fr 1.1fr 1fr;
}

.item-card .item-grid label {
  font-size: 0.72rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  font-size: 0.86rem;
  font-weight: 700;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #4b86f5);
  color: white;
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.28);
}

.secondary-button {
  background: linear-gradient(180deg, #f8fbff 0%, #eaf1ff 100%);
  color: var(--accent-dark);
  border: 1px solid rgba(47, 111, 237, 0.12);
}

.ghost-button {
  background: linear-gradient(180deg, #f9fbff 0%, #eef3fb 100%);
  color: var(--text);
  border: 1px solid rgba(185, 200, 220, 0.8);
}

.remove-button {
  background: var(--danger-soft);
  color: #b42318;
  padding-inline: 12px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  overflow: hidden;
}

.summary-card::before {
  content: "Calculated Invoice Totals";
  display: block;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1f57c7, #2f6fed);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
}

.summary-row + .summary-row {
  border-top: 1px solid var(--line);
}

.summary-row span {
  color: var(--muted);
}

.summary-row strong {
  letter-spacing: -0.02em;
}

.total-row {
  background: var(--surface-muted);
  font-size: 1rem;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 16px;
}

.edi-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#edi-output {
  min-height: 430px;
  padding: 16px;
  border-radius: var(--radius-lg);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  background: #0f1728;
  color: #eff4ff;
  border: 1px solid #1d2940;
}

.form-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.bottom-sections {
  display: grid;
  grid-template-columns: minmax(280px, 0.55fr) minmax(0, 1.45fr);
  gap: 24px;
  margin-top: 24px;
}

.output-panel {
  background: rgba(255, 255, 255, 0.76);
}

.hero-card,
.output-panel {
  border: 1px solid rgba(255, 255, 255, 0.85);
}

@media (max-width: 1180px) {
  .hero,
  .bottom-sections {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 20px, 1520px);
    padding-top: 18px;
  }

  .panel,
  .hero-card {
    padding: 18px;
  }

  .field-grid,
  .item-grid {
    grid-template-columns: 1fr;
  }

  .item-card .full-span {
    grid-column: 1 / -1;
  }

  .split-title {
    flex-direction: column;
    align-items: stretch;
  }

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