:root {
  --dark-purple: #1A0B1E;
  --white: #FFFFFF;
  --black: #000000;
  --paynes-gray: #586F7C;
  --glaucous: #7272AB;
  --shadow: rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

*:focus-visible {
  outline: 2px solid #d5daf8;
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Trebuchet MS", sans-serif;
  line-height: 1.45;
  color: var(--white);
  background:
    radial-gradient(circle at 10% 20%, rgba(114, 114, 171, 0.3), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(88, 111, 124, 0.35), transparent 50%),
    linear-gradient(160deg, var(--dark-purple) 0%, var(--black) 100%);
  min-height: 100vh;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-shell,
.panel,
.topbar {
  background: rgba(26, 11, 30, 0.78);
  border: 1px solid rgba(114, 114, 171, 0.35);
  border-radius: 14px;
  box-shadow: 0 12px 24px var(--shadow);
}

.login-shell {
  width: min(440px, 100%);
  padding: 1.4rem;
}

.topbar {
  margin: 1rem;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: start;
}

.topbar p {
  max-width: 52ch;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0.3px;
}

p {
  margin: 0.45rem 0;
}

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

.global-banner-wrap {
  margin: 0 1rem 0.5rem;
}

.global-banner {
  margin: 0;
}

.panel {
  padding: 1rem;
}

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

.panel-live {
  position: static;
}

.collapsible {
  margin-top: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.18);
}

.collapsible summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.collapsible[open] summary {
  margin-bottom: 0.5rem;
}

.stack-form {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.inline-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.stack-form.compact {
  margin-top: 0.3rem;
}

label {
  font-size: 0.86rem;
  color: #d2d9de;
}

input,
select,
button {
  border-radius: 9px;
  border: 1px solid rgba(114, 114, 171, 0.65);
  padding: 0.55rem 0.65rem;
  font: inherit;
}

input,
select {
  background: rgba(88, 111, 124, 0.18);
  color: var(--white);
}

input::file-selector-button {
  border: 1px solid rgba(114, 114, 171, 0.7);
  border-radius: 7px;
  background: rgba(88, 111, 124, 0.35);
  color: var(--white);
  margin-right: 0.55rem;
  padding: 0.35rem 0.5rem;
}

button {
  background: linear-gradient(135deg, var(--glaucous), #596aa7);
  color: var(--white);
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

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

button.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
}

button.danger {
  background: linear-gradient(120deg, #8f3a52, #b34f66);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.6rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  padding: 0.45rem;
  vertical-align: top;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.75rem;
  letter-spacing: 0.2px;
  text-transform: capitalize;
  font-weight: 600;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.status-queued {
  background: rgba(88, 111, 124, 0.35);
  border-color: rgba(88, 111, 124, 0.9);
}

.status-queued .status-dot {
  background: #8da1ac;
}

.status-running {
  background: rgba(114, 114, 171, 0.32);
  border-color: rgba(114, 114, 171, 0.9);
}

.status-running .status-dot {
  background: #9292d1;
}

.status-cancelling {
  background: rgba(179, 79, 102, 0.28);
  border-color: rgba(179, 79, 102, 0.8);
}

.status-cancelling .status-dot {
  background: #d18aa0;
}

.status-completed {
  background: rgba(54, 120, 90, 0.35);
  border-color: rgba(95, 186, 131, 0.85);
}

.status-completed .status-dot {
  background: #78d5a3;
}

.status-cancelled,
.status-failed {
  background: rgba(120, 48, 66, 0.38);
  border-color: rgba(190, 92, 117, 0.85);
}

.status-cancelled .status-dot,
.status-failed .status-dot {
  background: #e07b97;
}

.panel-jobs tbody tr {
  animation: riseIn 340ms ease both;
}

.panel-jobs tbody tr:nth-child(1) { animation-delay: 40ms; }
.panel-jobs tbody tr:nth-child(2) { animation-delay: 70ms; }
.panel-jobs tbody tr:nth-child(3) { animation-delay: 100ms; }
.panel-jobs tbody tr:nth-child(4) { animation-delay: 130ms; }
.panel-jobs tbody tr:nth-child(5) { animation-delay: 160ms; }
.panel-jobs tbody tr:nth-child(n+6) { animation-delay: 190ms; }

a {
  color: #d5daf8;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

.file-list {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.file-list li {
  display: block;
}

.file-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--white);
}

.file-check input {
  width: 1rem;
  height: 1rem;
}

.file-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.batch-form {
  margin-top: 0.4rem;
}

.banner {
  margin-top: 0.5rem;
  padding: 0.48rem 0.6rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.banner.success {
  background: rgba(54, 120, 90, 0.32);
  border: 1px solid rgba(95, 186, 131, 0.5);
}

.banner.error {
  background: rgba(120, 48, 66, 0.35);
  border: 1px solid rgba(190, 92, 117, 0.5);
}

.caption {
  opacity: 0.8;
  font-size: 0.82rem;
}

.live-progress {
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(114, 114, 171, 0.45);
  background: rgba(88, 111, 124, 0.15);
  font-size: 0.84rem;
}

.log-preview {
  margin-top: 0.55rem;
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.35);
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.78rem;
  line-height: 1.35;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  animation: glowPulse 2.4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 0 rgba(114, 114, 171, 0.15);
  }
  50% {
    box-shadow: 0 0 14px rgba(114, 114, 171, 0.25);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar form {
    width: 100%;
  }

  .topbar button {
    width: 100%;
  }

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

  .panel-live {
    position: static;
  }

  .panel {
    padding: 0.9rem;
  }

  th,
  td {
    font-size: 0.8rem;
    padding: 0.4rem;
  }

  .file-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .file-actions,
  .file-actions button {
    width: 100%;
  }

  input,
  select,
  button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .panel-jobs .table-wrap {
    overflow: visible;
  }

  .panel-jobs table,
  .panel-jobs tbody,
  .panel-jobs tr,
  .panel-jobs td {
    display: block;
    width: 100%;
  }

  .panel-jobs thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .panel-jobs tr {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.16);
    margin-bottom: 0.7rem;
    padding: 0.35rem 0.5rem;
  }

  .panel-jobs td {
    border: 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.65rem;
    text-align: right;
    font-size: 0.84rem;
  }

  .panel-jobs td:last-child {
    border-bottom: 0;
  }

  .panel-jobs td::before {
    content: attr(data-label);
    color: #d2d9de;
    font-size: 0.76rem;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }

  .panel-jobs td form {
    width: 100%;
  }

  .panel-jobs td[data-label="Action"] button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
