:root {
  color-scheme: light;
  --bg: #eef2f5;
  --ink: #101621;
  --muted: #667085;
  --panel: rgba(255, 255, 255, 0.82);
  --line: rgba(16, 22, 33, 0.12);
  --accent: #047b7f;
  --accent-2: #e85d4f;
  --accent-3: #e1a624;
  --danger: #c73232;
  --shadow: 0 18px 60px rgba(16, 22, 33, 0.1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  letter-spacing: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(4, 123, 127, 0.12), transparent 34%),
    linear-gradient(230deg, rgba(232, 93, 79, 0.14), transparent 38%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(238, 242, 245, 0.86);
  backdrop-filter: blur(18px);
}

.topbar h1,
.panel h2,
.preview-card h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1;
}

.panel h2,
.preview-card h2 {
  font-size: clamp(19px, 1.9vw, 28px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(4, 123, 127, 0.4);
  background: #fff;
}

.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.button.danger {
  color: var(--danger);
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.button.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.control-shell,
.preview-grid {
  display: grid;
  gap: 18px;
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.control-shell {
  grid-template-columns: repeat(12, 1fr);
  align-items: start;
}

.panel,
.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: clamp(18px, 2vw, 28px);
}

.status-panel {
  grid-column: span 8;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.status-panel + .panel {
  grid-column: span 4;
}

.counters-panel,
.route-panel,
.links-panel {
  grid-column: 1 / -1;
}

.section-title,
.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.callback-box {
  display: grid;
  gap: 8px;
  min-width: min(430px, 100%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.callback-box span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

code {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.wide {
  grid-column: span 3;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-weight: 760;
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: rgba(4, 123, 127, 0.62);
  box-shadow: 0 0 0 4px rgba(4, 123, 127, 0.12);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

#stages {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.stage-row {
  display: grid;
  grid-template-columns: 1.2fr 2fr minmax(120px, 0.7fr) 42px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--danger);
  font-size: 24px;
}

.obs-links {
  display: grid;
  gap: 16px;
}

.link-group {
  display: grid;
  gap: 8px;
}

.link-group strong {
  font-size: 15px;
}

.copy-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.copy-row span {
  color: var(--muted);
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  transform: translateY(20px);
  opacity: 0;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #101621;
  color: #fff;
  font-weight: 850;
  box-shadow: 0 20px 64px rgba(16, 22, 33, 0.24);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.preview-page {
  min-height: 100vh;
}

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

.preview-card {
  overflow: hidden;
}

.preview-head {
  margin: 0;
  padding: 18px;
}

.preview-card iframe {
  display: block;
  width: 100%;
  height: 540px;
  border: 0;
  background:
    linear-gradient(45deg, rgba(16, 22, 33, 0.86), rgba(47, 52, 61, 0.82)),
    #101621;
}

@media (max-width: 1000px) {
  .control-shell,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .status-panel,
  .status-panel + .panel,
  .counters-panel,
  .route-panel,
  .links-panel {
    grid-column: auto;
  }

  .status-panel {
    display: grid;
  }

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

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

@media (max-width: 680px) {
  .topbar,
  .section-title,
  .preview-head {
    display: grid;
  }

  .form-grid,
  .stage-row,
  .copy-row {
    grid-template-columns: 1fr;
  }

  .button,
  .icon-button {
    width: 100%;
  }
}
