:root {
  --bg-1: #091a33;
  --bg-2: #0f2a52;
  --panel: #f8fbff;
  --panel-strong: #ffffff;
  --text: #11243f;
  --muted: #59708d;
  --line: #d4e0ef;
  --navy: #14386b;
  --navy-strong: #0f2f5f;
  --navy-soft: #e8f0fb;
  --ok: #117a51;
  --warn: #8a5700;
  --error: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", "Noto Sans", sans-serif;
  background:
    radial-gradient(1200px 700px at 90% -10%, #2f4f80 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 10%, #21426f 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  border: 1px solid #c7d7ea;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(3, 14, 35, 0.36);
}

h1, h2 {
  margin-top: 0;
  letter-spacing: -0.02em;
}

h1 {
  color: #102748;
  font-size: clamp(2rem, 3.5vw, 2.85rem);
}

h2 {
  color: #163663;
  margin-top: 1.2rem;
}

.lead, .hint { color: var(--muted); }

.section-hint {
  margin: 0.35rem 0 0.7rem;
  font-weight: 700;
  color: #32537f;
}

.field-help {
  display: inline-block;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  color: #5f7592;
  font-size: 0.78rem;
  font-weight: 500;
}

fieldset {
  margin-bottom: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: #fafdff;
}

legend {
  font-weight: 700;
  color: #163663;
  padding: 0 0.3rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
  font-weight: 600;
  color: #27476d;
}

.label-with-tip {
  position: relative;
}

.label-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  margin-left: 0.4rem;
  background: #1f4c89;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  position: relative;
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: #eaf2fb;
  color: #203b60;
  border: 1px solid #b8cde6;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-width: 240px;
  max-width: 320px;
  white-space: normal;
  font-size: 0.75rem;
  line-height: 1.3;
  box-shadow: 0 10px 20px rgba(14, 34, 65, 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 80ms ease, transform 80ms ease, visibility 80ms ease;
  z-index: 20;
}

.tooltip-icon:hover::after,
.tooltip-icon:focus::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.tooltip-icon:focus {
  outline: 2px solid #2d63a7;
  outline-offset: 2px;
}

input, select {
  border: 1px solid #c6d7eb;
  border-radius: 9px;
  padding: 0.58rem 0.65rem;
  background: #ffffff;
  color: #11305a;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

input:focus, select:focus {
  outline: none;
  border-color: #2d63a7;
  box-shadow: 0 0 0 3px rgba(45, 99, 167, 0.14);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.95rem;
}

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

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.8rem 0;
}

.output-box {
  background: #fafdff;
  border-color: var(--line);
}

.output-box legend {
  color: #163663;
}

.checks-vertical {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.checks-vertical label {
  margin-bottom: 0;
}

.checks-vertical .label-title {
  align-items: center;
}

button {
  border: none;
  background: linear-gradient(180deg, #1f4c89, var(--navy-strong));
  color: #fff;
  font-weight: 700;
  padding: 0.78rem 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17, 50, 97, 0.28);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(17, 50, 97, 0.33);
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.secondary-btn {
  background: #edf3fb;
  color: #183d71;
  border: 1px solid #c4d5eb;
  box-shadow: none;
}

.secondary-btn:hover {
  background: #e3edf9;
  transform: translateY(-1px);
  box-shadow: none;
}

.alert {
  padding: 0.75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert.error {
  background: #fef1f2;
  color: var(--error);
  border-color: #f9c8cf;
}

.upload-progress {
  margin-top: 0.95rem;
  color: #26476f;
  font-weight: 600;
}

.upload-progress progress {
  width: 100%;
  height: 14px;
  border-radius: 999px;
}

.hidden {
  display: none !important;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-queued {
  background: #fff6e6;
  color: var(--warn);
}

.status-running {
  background: var(--navy-soft);
  color: #1f4c89;
}

.status-completed {
  background: #e8f8ef;
  color: var(--ok);
}

.status-failed {
  background: #fef1f2;
  color: var(--error);
}

.running-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #ccdaeb;
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.phase-list {
  margin: 0.5rem 0 1rem 1.2rem;
  padding: 0;
}

.phase-item {
  margin: 0.3rem 0;
  color: var(--muted);
}

.phase-item.active {
  color: #1f4c89;
  font-weight: 700;
}

.phase-item.done {
  color: var(--ok);
  font-weight: 700;
}

.phase-item.failed {
  color: var(--error);
  font-weight: 700;
}

.log-tail {
  max-height: 320px;
  overflow: auto;
  background: linear-gradient(180deg, #081630, #071229);
  color: #d7e8ff;
  border-radius: 10px;
  border: 1px solid #17335f;
  padding: 0.95rem;
  font-size: 0.83rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

a {
  color: #1a4d90;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

a:hover {
  color: #143b70;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

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

  .container {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    border: none;
    box-shadow: none;
  }
}

.interactive-frame {
  width: 100%;
  min-height: 720px;
  border: 1px solid #c6d7eb;
  border-radius: 10px;
  background: #ffffff;
}
