* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f6f7f9;
  color: #1f2933;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a {
  color: #0f5e9c;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #17324d;
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 14px 24px;
}

.brand {
  color: #fff;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.nav a {
  color: #dce9f5;
}

.nav a.active {
  color: #fff;
  border-bottom: 2px solid #fff;
  padding-bottom: 2px;
}

.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-chip {
  appearance: none;
  background: none;
  border: none;
  color: #dce9f5;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.user-chip:hover {
  color: #fff;
}

.user-dropdown {
  background: #fff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
  min-width: 180px;
  padding: 4px 0;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 200;
}

.user-dropdown-item {
  appearance: none;
  background: none;
  border: none;
  color: #1f2933;
  cursor: pointer;
  display: block;
  font-size: 14px;
  padding: 9px 16px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.user-dropdown-item:hover {
  background: #f0f5fa;
  text-decoration: none;
}

.user-dropdown-logout {
  color: #b91c1c;
}

.user-dropdown-divider {
  border-top: 1px solid #e5eaf0;
  margin: 4px 0;
}

.content {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 24px 48px;
}

.page-title {
  margin: 0 0 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.card {
  background: #fff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  padding: 16px;
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
}

.stat-label {
  color: #5f6f7f;
}

.table-wrap {
  background: #fff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e6ebf0;
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4f8;
  color: #435364;
  font-size: 13px;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  text-transform: uppercase;
}

.status.completed,
.status.completed_with_cancellations,
.status.running,
.status.updating_visibility,
.status.downloading,
.status.packaging,
.status.uploading {
  background: #dff4e8;
  color: #17663a;
}

.status.failed {
  background: #fde2e2;
  color: #9f1d1d;
}

.status.cancelled {
  background: #eee;
  color: #435364;
}

.status.pending,
.status.held,
.status.retry_pending {
  background: #fff1cc;
  color: #7b5300;
}

.muted {
  color: #687789;
}

.stack {
  display: grid;
  gap: 16px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-event {
  border-left: 4px solid #91b6d9;
  padding: 8px 12px;
}

.log-event.error-event {
  border-left-color: #9f1d1d;
}

.log-meta {
  color: #687789;
  font-size: 13px;
}

.error-text {
  color: #9f1d1d;
  font-weight: 700;
}

pre {
  background: #f3f6f9;
  border-radius: 6px;
  overflow-x: auto;
  padding: 10px;
}

.login-panel {
  margin: 80px auto;
  max-width: 440px;
}

.button {
  background: #0f5e9c;
  border-radius: 6px;
  color: #fff;
  display: inline-block;
  font-weight: 700;
  padding: 10px 14px;
}

.button:hover {
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.secondary {
  background: #435364;
}

.button.danger {
  background: #9f1d1d;
}

.button.compact {
  font-size: 13px;
  padding: 7px 10px;
}

.button-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.queue-toolbar {
  margin-bottom: 14px;
}

.queue-actions-cell {
  min-width: 360px;
}

.queue-inline-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.queue-inline-actions label {
  min-width: 150px;
}

.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-action {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.source-action input[type="file"] {
  max-width: 260px;
}

.compact-list {
  color: #435364;
  margin: 10px 0 0;
  padding-left: 22px;
}

.compact-list li + li {
  margin-top: 4px;
}

.job-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.job-pill {
  background: #dff4e8;
  border: 1px solid #8fd1aa;
  border-radius: 999px;
  color: #17663a;
  display: inline-flex;
  font-weight: 700;
  padding: 5px 10px;
}

.form-grid {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  color: #435364;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 5px;
}

.field-label {
  color: #435364;
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

input,
select {
  border: 1px solid #c9d3dd;
  border-radius: 6px;
  font: inherit;
  padding: 9px 10px;
}

.visibility-action-group {
  display: grid;
  gap: 5px;
}

.target-visibility-row {
  align-items: center;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.target-visibility-row select {
  min-width: 180px;
}

.visibility-menu {
  position: relative;
}

.visibility-menu summary {
  border: 1px solid #c9d3dd;
  border-radius: 6px;
  cursor: pointer;
  display: block;
  min-width: 112px;
  padding: 8px 10px;
}

.visibility-menu-panel {
  background: #fff;
  border: 1px solid #c9d3dd;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.15);
  display: grid;
  gap: 6px;
  left: 0;
  min-width: 150px;
  padding: 8px;
  position: absolute;
  top: calc(100% + 4px);
  z-index: 5;
}

.notice {
  background: #fff1cc;
  margin-bottom: 16px;
}

/* ── Current Pipeline header ───────────────────────────────── */

.cp-header {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.cp-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
  color: #435364;
}

.cp-ready-badge {
  background: #dff4e8;
  border: 1px solid #8fd1aa;
  border-radius: 999px;
  color: #17663a;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
}

/* ── Pipeline stat boxes ───────────────────────────────────── */

.pipeline-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .pipeline-stats {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

.stat-card {
  appearance: none;
  background: #fff;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  color: #1f2933;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  text-align: left;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  border-color: #91b6d9;
  box-shadow: 0 2px 8px rgba(15, 94, 156, 0.1);
  text-decoration: none;
}

.stat-card--selected {
  border-color: #17663a;
  box-shadow: 0 0 0 2px rgba(23, 102, 58, 0.12);
}

.stat-card--selected .stat-label {
  color: #17663a;
}

.stat-card--open {
  border-color: #0f5e9c;
  box-shadow: 0 0 0 2px rgba(15, 94, 156, 0.15);
}

/* ── Pipelette panels ──────────────────────────────────────── */

.pipelette-panel {
  margin-top: 8px;
}

.pipelette-panel-inner {
  background: #fff;
  border: 1px solid #91b6d9;
  border-radius: 8px;
  padding: 16px 20px;
}

.pipelette-panel-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
  color: #435364;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pipelette-item {
  align-items: center;
  border-bottom: 1px solid #e6ebf0;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
}

.pipelette-item:last-child {
  border-bottom: none;
}

.pipelette-item--active {
  background: #f4fbf6;
  border-radius: 6px;
  margin: 0 -8px;
  padding: 10px 8px;
}

.pipelette-item--active + .pipelette-item--active {
  margin-top: 4px;
}

.pipelette-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pipelette-item-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipelette-item-info .muted {
  font-size: 12px;
}

.pipelette-item-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

/* ── Conveyor belt (pipeline running indicator) ── */
.pl-conveyor {
  height: 7px;
  margin: 6px 32px 0;
  border-radius: 4px;
  overflow: hidden;
  background: repeating-linear-gradient(
    90deg,
    #1a56a0 0px,
    #1a56a0 12px,
    #c9d3dd 12px,
    #c9d3dd 20px
  );
  background-size: 40px 100%;
  animation: conveyor-belt 0.7s linear infinite;
}

@keyframes conveyor-belt {
  from { background-position: 0 0; }
  to   { background-position: 40px 0; }
}

/* Active state for panel-toggle buttons */
.src-panel-toggle.active,
.lst-panel-toggle.active {
  background: #1a56a0;
  color: #fff;
  border-color: #1a56a0;
}
