:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1b2f;
  --panel-2: #10233d;
  --line: #1d3a63;
  --text: #e5edf8;
  --muted: #93a9c6;
  --blue: #2f6df6;
  --cyan: #14b8a6;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #ef4444;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #102b4d 0, #07111f 34%, #030814 100%);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
button, input, textarea, select { font: inherit; }
.app { min-height: 100vh; padding: 22px; }
.hero {
  display: flex; align-items: center; gap: 16px; margin: 0 auto 18px; max-width: 1320px;
}
.logo {
  width: 62px; height: 62px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #020617, #1d4ed8, #7c3aed);
  color: white; font-weight: 900; box-shadow: 0 12px 34px rgba(37,99,235,.22);
}
h1 { margin: 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: 0; }
.sub { color: var(--muted); margin-top: 4px; }
.badge { margin-left: auto; background: #0f766e; color: #ecfeff; font-weight: 800; padding: 12px 18px; border-radius: 4px; }
.grid { max-width: 1320px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.card {
  background: rgba(13,27,47,.94); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px rgba(59,130,246,.08);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { color: #8bd3ff; font-size: 18px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
input, textarea, select {
  width: 100%; background: #081426; border: 1px solid #224672; color: var(--text);
  padding: 12px 13px; outline: none; border-radius: 4px;
}
textarea { min-height: 130px; resize: vertical; font-family: Consolas, ui-monospace, monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,109,246,.14); }
button {
  border: 1px solid rgba(255,255,255,.28); background: var(--panel-2); color: var(--text);
  padding: 11px 16px; border-radius: 4px; cursor: pointer; font-weight: 800;
}
button.primary { background: var(--blue); }
button.good { background: var(--green); }
button.warn { background: #854d0e; }
button.danger { background: #991b1b; }
button:disabled { opacity: .55; cursor: not-allowed; }
.status { margin-top: 10px; color: var(--muted); min-height: 22px; }
.ok { color: #22c55e; }
.bad { color: var(--red); }
.wait { color: var(--amber); }
table { width: 100%; border-collapse: collapse; overflow: hidden; }
th, td { border: 1px solid #365174; padding: 9px 10px; text-align: left; vertical-align: top; }
th { color: #8bd3ff; background: #132642; }
td { background: rgba(8,20,38,.7); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hidden { display: none !important; }
.pill { display:inline-block; padding: 3px 8px; border-radius: 999px; background:#132642; color:#c7d7ed; font-size:12px; }
.scroll { overflow: auto; max-height: 50vh; border: 1px solid #18355b; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.tabs button.active { background: var(--blue); }
.copybox { white-space: pre-wrap; font-family: Consolas, ui-monospace, monospace; background:#081426; border:1px solid #224672; padding:12px; min-height:80px; }
@media (max-width: 1040px) {
  .grid { grid-template-columns: 1fr; }
  .badge { display: none; }
}
@media (max-width: 680px) {
  .app { padding: 12px; }
  .hero { align-items: flex-start; }
  .logo { width: 48px; height: 48px; }
  .split { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
  button { width: 100%; }
}

.customer-shell {
  background: #07111f;
  min-width: 320px;
  overflow-x: auto;
}

.customer-app {
  width: min(100%, 1540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 2.1vw, 28px);
}

.customer-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 1.8vw, 22px);
  align-items: center;
  margin-bottom: clamp(18px, 3vw, 38px);
}

.brand-mark {
  width: clamp(54px, 6vw, 84px);
  aspect-ratio: 1.6 / 1;
  object-fit: cover;
  background: #081426;
  border: 1px solid rgba(139, 211, 255, .08);
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 48px);
  line-height: 1.06;
  letter-spacing: 0;
  color: #fff7e8;
  text-shadow: 0 1px 0 #000, 0 0 12px rgba(246, 199, 92, .14);
}

.brand-copy p {
  margin: 9px 0 0;
  color: #8fb0d7;
  font-size: clamp(14px, 1.35vw, 18px);
}

.mode-badge {
  justify-self: end;
  background: #0f766e;
  color: #ecfeff;
  border: 1px solid rgba(45, 212, 191, .32);
  padding: 12px 20px;
  min-width: 170px;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 10px 28px rgba(15, 118, 110, .18);
}

.customer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 34%);
  gap: clamp(12px, 1.6vw, 18px);
  align-items: stretch;
}

.primary-stack,
.side-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pz-panel {
  min-width: 0;
  background: #0d1b2f;
  border: 2px solid #1d3f6f;
  box-shadow: inset 0 0 0 1px rgba(142, 191, 255, .08), 0 12px 28px rgba(0, 0, 0, .12);
  padding: clamp(12px, 1.45vw, 18px);
}

.pz-panel h2 {
  margin: -6px 0 10px;
  color: #7ed3ff;
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.2;
}

.input-row {
  border: 2px solid #214678;
  padding: clamp(8px, 1vw, 12px);
}

.input-row input,
.inquiry-panel input {
  min-height: 48px;
  font-family: Consolas, ui-monospace, monospace;
  font-size: clamp(15px, 1.25vw, 18px);
}

.status-band,
.inline-status,
.route-box,
.run-status {
  min-height: 38px;
  background: #0b1728;
  color: #b9c7da;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  overflow-wrap: anywhere;
}

.status-band.ok,
.inline-status.ok,
.route-box.ok,
.run-status.ok { color: #14c76f; }

.status-band.bad,
.inline-status.bad,
.route-box.bad,
.run-status.bad { color: #f87171; }

.status-band.wait,
.inline-status.wait,
.route-box.wait,
.run-status.wait { color: #f8c35b; }

.session-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.session-toolbar p {
  margin: 0;
  color: #c7d7ed;
  overflow-wrap: anywhere;
}

.session-toolbar span {
  color: #eecf78;
}

.button-pair,
.run-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

#sessionPaste {
  min-height: clamp(145px, 22vh, 265px);
  max-height: 42vh;
  border-radius: 0;
  border-color: #14315a;
  background: #081426;
  color: #dbeafe;
  line-height: 1.35;
}

#sessionPaste:disabled {
  color: #6f8199;
  background: #08111f;
}

.session-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.route-box {
  min-height: 58px;
  font-size: clamp(14px, 1.2vw, 17px);
}

.run-panel {
  margin-bottom: 0;
}

.progress-track {
  height: 20px;
  margin: 12px 0 14px;
  background: #10233d;
  border: 1px solid #123055;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #34d399, #eecf78);
  transition: width .24s ease;
}

.run-actions button,
.button-pair button,
.inquiry-panel button,
.session-actions button {
  min-width: 130px;
}

.result-panel,
.log-panel {
  flex: 1 1 auto;
}

.table-wrap {
  border: 1px solid #365174;
  overflow: auto;
  max-height: min(42vh, 460px);
}

.table-wrap table {
  min-width: 520px;
}

.table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #172842;
}

.table-wrap td:nth-child(2) {
  color: #f7d77d;
  font-weight: 700;
}

.inquiry-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.inquiry-panel h2,
.inquiry-panel .safe-box {
  grid-column: 1 / -1;
}

.safe-box {
  min-height: 90px;
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  background: #081426;
  color: #dbeafe;
  border: 1px solid #102a4d;
  padding: 12px;
  font-family: Consolas, ui-monospace, monospace;
}

.log-panel .safe-box {
  min-height: 110px;
  color: #b9c7da;
}

@media (max-width: 1120px) {
  .customer-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 34%);
  }

  .log-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .customer-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .mode-badge {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-width: 0;
  }

  .session-toolbar,
  .session-actions,
  .side-stack,
  .inquiry-panel {
    grid-template-columns: 1fr;
  }

  .button-pair,
  .run-actions {
    justify-content: stretch;
  }

  .table-wrap table {
    min-width: 420px;
  }

  .button-pair button,
  .run-actions button,
  .inquiry-panel button,
  .session-actions button {
    width: 100%;
    min-width: 0;
  }

  .customer-app {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .customer-header {
    align-items: start;
  }

  .brand-mark {
    width: 58px;
  }

  .brand-copy h1 {
    font-size: 25px;
  }

  .brand-copy p {
    font-size: 13px;
  }

  .pz-panel {
    padding: 10px;
  }

  #sessionPaste {
    min-height: 150px;
  }
}
